<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
 <link rel="stylesheet" href="../static/css/back/font.css">
 <link rel="stylesheet" href="../static/css/back/role.css">
    <link rel="stylesheet" href="../static/css/back/xadmin.css">
    <script type="text/javascript" src="../static/js/jquery-2.1.1.min.js"></script>
    
    <script type="text/javascript" src="../static/js/back/xadmin.js"></script>
    <script type="text/javascript" src="../static/js/back/ajax.js"></script>
    <script type="text/javascript" src="../static/js/back/utils.js"></script>
    
<!--      <script type="text/javascript" src="../static/js/back/admin-rule.js"></script> -->
   
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style type="text/css">
.layui-form-label {
	width: 150px !important;
}
.savebtn .layui-btn{
	padding: 0 50px;
}
.botty{
position: absolute;
bottom: 100px;
}
.botty a{
	color:  blue;
	cursor: pointer;
}
</style>
  </head>
  <body>
   <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="javascript:;">首页</a>
        <a href="javascript:;"></a>
        <a href="javascript:;"><cite></cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="iconfont icon-refresh right-top-ref" ></i></a>
    </div>
    <div class="x-body">
      <form action="" method="post" class="layui-form" lay-verify="formAdd" onsubmit="javascript:return false;">
	      <div class="jiedan-set hide">
		      <div class="layui-form-item is_up_do">
		        <label class="layui-form-label">外卖接单方式</label>
		        <div class="layui-input-block">
		          <input type="radio" name="getOrderOut" value="1" title="手动接单" lay-filter='out'>
		          <input type="radio" name="getOrderOut" value="2" title="自动接单" lay-filter='out'>
		        </div>
		      </div>
		      <div class="layui-form-item is_up_do">
		        <label class="layui-form-label">堂食接单方式</label>
		        <div class="layui-input-block">
		          <input type="radio" name="getOrderRoom" value="1" title="手动接单" lay-filter='room'>
		          <input type="radio" name="getOrderRoom" value="2" title="自动接单" lay-filter='room'>
		          <input type="radio" name="getOrderRoom" value="3" title="微信支付自动接单 , 现金结算手动接单" lay-filter='room'>
		        </div>
		      </div>
	      </div>
	      <div class="jiedan-tixing hide">
		      <div class="layui-form-item is_up_do">
		        <label class="layui-form-label">开启重复播报</label>
		        <div class="layui-input-block">
		          <input type="radio" name="isRepeatReport" value="0" title="否" lay-filter='report'>
		          <input type="radio" name="isRepeatReport" value="1" title="是" lay-filter='report'>
		        </div>
		      </div>
	      </div>
	      <div class="jiedan-print hide">
		      
		      <div class="layui-tab " lay-filter="docDemoTabBrief">
				  <ul class="layui-tab-title">
				    <li class="layui-this">打印设置</li>
				    <li>打印机设置</li>
				  </ul>
				  <div class="layui-tab-content" style="height: 100px;">
				    <div class="layui-tab-item layui-show">
				    	<div class="layui-form-item is_up_do">
					        <label class="layui-form-label">接单后自动打印小票</label>
					        <div class="layui-input-block" style="pointer-events:none;" >
					          <input type="radio" name="printAuto" value="1" title="是" lay-filter='printAuto'>
					          <input type="radio" name="printAuto" value="0" title="否" lay-filter='printAuto'>
					        </div>
					      </div>
					      <div class="layui-form-item hide">
					        <label class="layui-form-label"></label>
					        <button class="layui-btn" lay-submit="" lay-filter="add">保存</button>
					      </div>
					      <div class="layui-form-item botty">
					        <hr>
					        <label class="layui-form-label">说明</label>
					         本站USB打印机需安装打印插件，如果您的打印机为USB连接方式，请务必<a href="http://www.lodop.net/download/CLodop_Setup_for_Win32NT_https_3.060Extend.zip" target="_self">下载安装</a><br>（若此前已安装过，可<a href="CLodop.protocol:setup" target="_self">点这里直接再次启动</a>）
					      </div>
				    </div>
				    <div class="layui-tab-item">
				    	<div class="x-body">
					      <xblock>
					<!--         <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button> -->
					        <button class="layui-btn" onclick="x_admin_show('添加打印机','./shops~shop-print-add.html?type=add',451,580)"><i class="layui-icon"></i>添加</button>
					        <span class="x-right" style="line-height:40px">共有数据：0 条</span>
					      </xblock>
					      <table class="layui-table">
					        <thead>
					          <tr>
					            <th>排序</th>
					            <th>打印机名称</th>
					            <th>打印机位置</th>
					            <th>打印机类型</th>
					            <th>状态</th>
					            <th>操作</th>
					        </thead>
					        <tbody>
					        </tbody>
					      </table>
					      <div class="layui-form-mid layui-word-aux no-more-data hide">暂无更多数据</div>
					      <div class="page mypage" ></div> 
					      </div>
				    </div>
				  </div>
				</div> 
		      
	      </div>
	      <div class="shop-table hide">
		      <div class="layui-form-item is_up_do hide">
		        <label class="layui-form-label">堂食付款方式</label>
		        <div class="layui-input-block">
		          <input type="radio" name="payType" value="3" title="微信+线下" lay-filter='payType'>
		          <input type="radio" name="payType" value="1" title="微信" lay-filter='payType'>
		          <input type="radio" name="payType" value="2" title="线下" lay-filter='payType'>
		        </div>
		      </div>
		      <div class="layui-form-item is_up_do">
		        <label class="layui-form-label">餐具费</label>
		        <div class="layui-input-block">
		          <input type="radio" name="tablewareFee" value="0" title="不收取" lay-filter='tablewareFee'>
		          <input type="radio" name="tablewareFee" value="1" title="收取" lay-filter='tablewareFee'>
		        </div>
		      </div>
		      <div class="layui-form-item  hide tablewarePrice">
		        <label class="layui-form-label">餐具价格</label>
		        <div class="layui-input-inline">
		          <input type="text" id="tablewarePrice" name="tablewarePrice"  
		             lay-verify=""  autocomplete="off" class="layui-input"
		            placeholder="请输入单套餐具的价格">
		        </div>
		        <div class="layui-form-mid layui-word-aux">元</div>
		      </div>
	      </div>
	      <div class="layui-form-item savebtn  hide">
	        <label class="layui-form-label"></label>
	        <button class="layui-btn" lay-submit="" lay-filter="add">保存</button>
	      </div>
    </form>
    </div>
    <script type="text/javascript">
    	
    
    
    </script>
    <script>
    _ddd = null;
    var spid = getCookie('shop_id');
    layui.use(['form','layer'], function(){
        $ = layui.jquery,
     	form = layui.form
      ,layer = layui.layer;
      //先处理url参数
      showChuData();
     
      //监听提交
      form.on('submit(add)', function(data){
        console.log(data.field);
        if(data.field.tablewarePrice){
        	data.field.tablewarePrice = (data.field.tablewarePrice * 100 ).toFixed(0);
        }
        saveSet(data.field);
        return false;
      });
      form.on('radio(tablewareFee)', function(data){
        console.log(data.value);
        if(data.value == 1){
        	$('.tablewarePrice').show();
        	$("#tablewarePrice").attr('lay-verify','number');
        }else{
        	$('.tablewarePrice').hide();
        	$("#tablewarePrice").attr('lay-verify','');
        }
        return false;
      });
      
      console.log(_ddd);
      form.render();
      form.val("formAdd", _ddd);
      form.render('radio');
      
      $(".layui-btn").click(function(){
      	console.log($(this).text());
      });
    });
    var sty = getUrlParam("stype");
    //进入页面执行
    function showChuData(){
    	_ajax_get_token('../shop/getShopSetBySID',{shopId:spid},function(res){
    		console.log(res);
    		var d = res.returnObject;
    		$(".savebtn").show();
    		switch (sty) {
   			case "1":
   				//接单设置
   				$("cite").text("接单设置").parent().prev().prev().text("系统设置");
	    		 $("input[name=getOrderOut][value="+d.getOrderOut+"]").prop("checked", true);
	    		 $("input[name=getOrderRoom][value="+d.getOrderRoom+"]").prop("checked", true);
	            form.render();
	         	$(".jiedan-set").show();
   				break;
   			case "2":
   				$("cite").text("接单提醒").parent().prev().prev().text("系统设置");
	    		 $("input[name=isRepeatReport][value="+d.isRepeatReport+"]").prop("checked", true);
	            form.render();
	         	$(".jiedan-tixing").show();
   				break;
   			case "3":
   				$("cite").text("打印设置").parent().prev().prev().text("系统设置");
	    		 $("input[name=printAuto][value="+d.printAuto+"]").prop("checked", true);
	            form.render();
	         	$(".jiedan-print").show();
	         	$(".savebtn").hide();
	         	//获取打印机列表
	         	$(".x-body").append('<script type="text/javascript" src="../static/js/back/printer-list.js"></scrip'+'t>');
   				break;
   			case "4":
   				$("cite").text("桌台设置").parent().prev().prev().text("桌台管理");
	    		 $("input[name=payType][value="+d.payType+"]").prop("checked", true);
	    		 $("input[name=tablewareFee][value="+d.tablewareFee+"]").prop("checked", true);
	            form.render();
	            if(d.tablewareFee == 1){
	            	$(".tablewarePrice").show();
	            	$("#tablewarePrice").val((d.tablewarePrice/100).toFixed(2));
	            }
	         	$(".shop-table").show();
   				break;
   			default:
   				break;
   	  		}
    		
    	})
    }
    
    function saveSet(data){
    	data['shopId'] = spid;
    	_ajax_post_token('../shop/updateShopSetBySID',data,function(res){
    		console.log(res);
    		if(res.resultCode === 1000 ){
    			layer.msg('保存成功!',{icon:6,time:2000});
    		}
    	});
    }
    </script>

  </body>

</html>